# == the code

# maxima of function

f <- function(x){
  return (x^3-2*x+1)
}


plot(f, 0, 2, xlab = "x", ylab = "y", main = "quadratic curve", col = "blue")
grid(nx = 10, ny = 10, lwd = 2)

s <- optim(par = 0, f, method = c("Brent"), lower = -100, upper = 100, 
           control = list(fnscale = -1))
cat("value ", s$value, 
    "\nparameter ", s$par, "\n")